import Mock from 'mockjs'
import FilmList from '../data/film_list.json'

Mock.mock('/login', 'post', function(options) {
	let body = JSON.parse(options.body);
	let userList = localStorage.getItem("user");
	userList = JSON.parse(userList);
	let rt = userList.find(function(val) {
		return val.name == body.name && val.password == body.password;
	});
	if (rt) {
		return `{
					  "code": 200,
					  "message": "成功!",
					  "result": {
						"nickname": "${rt.nickname}"
					  }
					}`;
	} else {
		return `{
					  "code": 500,
					  "message": "失败!",
					  "result": {
						"nickname": ""
					   }
					}`;
	}
})
